DEFINITION MODULE Clock;

   (* This module defines procedures used for manipulating the *)
   (* Clock accessory.                                         *)


   IMPORT Text;


   VAR TimerResolution : INTEGER;

      (* Defines the minimum timer resolution needed for time events. *)


   PROCEDURE Initialize ();

      (* Initialize the clock upon system power-up *)


   PROCEDURE DayPeriod () : BOOLEAN;

      (* Return TRUE if the current time is between 8:00 am and *)
      (* 4:59 pm inclusive, otherwise return FALSE.             *)


   PROCEDURE EveningPeriod () : BOOLEAN;

      (* Return TRUE if the current time is between 5:00 pm and *)
      (* 10:59 pm inclusive, otherwise return FALSE.            *)


   PROCEDURE NightPeriod () : BOOLEAN;

      (* Return TRUE if the current time is between 11:00 pm and *)
      (* 7:59 am inclusive, otherwise return FALSE.              *)


   PROCEDURE SetTime ();

      (* Invoke a dialog box allowing the user to set the time. *)


   PROCEDURE SetDate ();

      (* Invoke a dialog box allowing the user to set the date. *)


   PROCEDURE OwnsWindow ( WindowId : INTEGER ) : BOOLEAN;

      (* Return TRUE if the clock owns the window specified by *)
      (* "WindowId", or FALSE otherwise.                       *)


   PROCEDURE DecodeTime ( Time              : CARDINAL;
                          UseFormat         : BOOLEAN;
                          VAR FormattedTime : ARRAY OF CHAR ); 

      (* Convert "Time" from it's encoded representation into *)
      (* the text string "FormattedTime".                     *)


   PROCEDURE DecodeDate ( Date              : CARDINAL;
                          UseFormat         : BOOLEAN;
                          VAR FormattedDate : ARRAY OF CHAR );

      (* Convert "Date" from it's encoded representation into *)
      (* the text string "FormattedDate".                     *)


   PROCEDURE EncodeTime ( VAR FormattedTime : ARRAY OF CHAR;
                          PM                : BOOLEAN;
                          VAR Time          : CARDINAL ) : BOOLEAN;


      (* Convert "FormattedTime" from a text string into the encoded *)
      (* representation "Time".                                      *)


   PROCEDURE EncodeDate ( VAR FormattedDate : ARRAY OF CHAR;
                          VAR Date          : CARDINAL ) : BOOLEAN;

      (* Convert "FormattedDate" from a text string into the encoded *)
      (* representation "Date".                                      *)


   PROCEDURE Open;

      (* Open the clock.  If the clock is already opened, *)
      (* then top the window belonging to the clock.      *)


   PROCEDURE Close;

      (* Close the clock window. *)


   PROCEDURE ProcessTimerEvent;

      (* The time specified has elapsed, so process the event. *)


   PROCEDURE ProcessMessageEvent ( VAR MsgBuffer : ARRAY OF INTEGER );

      (* Process a message event not relating to a menu. *)


   PROCEDURE ProcessButtonEvent ( MouseButton : INTEGER;
                                  ModifierKey : INTEGER;
                                  Clicks      : INTEGER );

      (* The mouse button has been pressed, so process the event. *)


   PROCEDURE ProcessKeyboardEvent ( Key         : INTEGER;
                                    ModifierKey : INTEGER );

      (* A key on the keyboard has been pressed, so process the event. *)


END Clock.

